<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1987-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation.  A copy of
the license is included in the
section entitled "GNU Free Documentation License".

This manual contains no Invariant Sections.  The Front-Cover Texts are
(a) (see below), and the Back-Cover Texts are (b) (see below).

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Include Syntax (The C Preprocessor)</title>

<meta name="description" content="Include Syntax (The C Preprocessor)">
<meta name="keywords" content="Include Syntax (The C Preprocessor)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Index-of-Directives.html" rel="index" title="Index of Directives">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Header-Files.html" rel="up" title="Header Files">
<link href="Include-Operation.html" rel="next" title="Include Operation">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Include-Syntax">
<div class="nav-panel">
<p>
Next: <a href="Include-Operation.html" accesskey="n" rel="next">Include Operation</a>, Up: <a href="Header-Files.html" accesskey="u" rel="up">Header Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Include-Syntax-1"><span>2.1 Include Syntax<a class="copiable-link" href="#Include-Syntax-1"> &para;</a></span></h3>

<a class="index-entry-id" id="index-_0023include"></a>
<p>Both user and system header files are included using the preprocessing
directive &lsquo;<samp class="samp">#include</samp>&rsquo;.  It has two variants:
</p>
<dl class="table">
<dt><code class="code">#include &lt;<var class="var">file</var>&gt;</code></dt>
<dd><p>This variant is used for system header files.  It searches for a file
named <var class="var">file</var> in a standard list of system directories.  You can prepend
directories to this list with the <samp class="option">-I</samp> option (see <a class="pxref" href="Invocation.html">Invocation</a>).
</p>
</dd>
<dt><code class="code">#include &quot;<var class="var">file</var>&quot;</code></dt>
<dd><p>This variant is used for header files of your own program.  It
searches for a file named <var class="var">file</var> first in the directory containing
the current file, then in the quote directories and then the same
directories used for <code class="code">&lt;<var class="var">file</var>&gt;</code>.  You can prepend directories
to the list of quote directories with the <samp class="option">-iquote</samp> option.
</p></dd>
</dl>

<p>The argument of &lsquo;<samp class="samp">#include</samp>&rsquo;, whether delimited with quote marks or
angle brackets, behaves like a string constant in that comments are not
recognized, and macro names are not expanded.  Thus, <code class="code">#include&nbsp;&lt;x/*y&gt;<!-- /@w --></code> specifies inclusion of a system header file named <samp class="file">x/*y</samp>.
</p>
<p>However, if backslashes occur within <var class="var">file</var>, they are considered
ordinary text characters, not escape characters.  None of the character
escape sequences appropriate to string constants in C are processed.
Thus, <code class="code">#include&nbsp;&quot;x\n\\y&quot;<!-- /@w --></code> specifies a filename containing three
backslashes.  (Some systems interpret &lsquo;<samp class="samp">\</samp>&rsquo; as a pathname separator.
All of these also interpret &lsquo;<samp class="samp">/</samp>&rsquo; the same way.  It is most portable
to use only &lsquo;<samp class="samp">/</samp>&rsquo;.)
</p>
<p>It is an error if there is anything (other than comments) on the line
after the file name.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Include-Operation.html">Include Operation</a>, Up: <a href="Header-Files.html">Header Files</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index-of-Directives.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
